package com.atguigu.service;

import com.atguigu.entity.Employee;
import com.atguigu.mapper.EmployeeMapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author : leimingchao
 * @version V1.0
 * @Project: mybatis
 * @Package com.atguigu.service
 * @Description: TODO
 * @date Date : 2021年05月23日 18:22
 */
@Service
public class EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    public Employee getOne(Employee employeeQueryCOndition) {
        return employeeMapper.selectOne(employeeQueryCOndition);
    }

    public Employee getEmployeeById(Integer id) {
        return employeeMapper.selectByPrimaryKey(id);
    }

    public boolean isExists(Integer id) {
        return employeeMapper.existsWithPrimaryKey(id);
    }


    public Integer saveEmployee(Employee employee) {
        return employeeMapper.insert(employee);
    }

    public Integer saveEmployeeSelect(Employee employee) {
        return employeeMapper.insertSelective(employee);
    }

    public Integer updateEmployeeSelective(Employee employee) {
        return employeeMapper.updateByPrimaryKeySelective(employee);
    }

    public Integer delete(Employee employee) {
        return employeeMapper.delete(employee);
    }

    public Integer deleteEmployeeByPrimary(Employee employee) {
        return employeeMapper.deleteByPrimaryKey(employee);
    }

    public List<Employee> getEmployeeListByExample(Example example) {
        return employeeMapper.selectByExample(example);
    }

    public List<Employee> getEmployeeListByRowBounds(RowBounds rowBounds) {
        return employeeMapper.selectByRowBounds(null,rowBounds);
    }
}
